class MyStaticObject:
	def __init__(self, fun):
		self.fun = fun;

	def __get__(self, instance, owner):
		return self.fun

def my_static_method(fun):
	return MyStaticObject(fun)

class MyClassObject:
	def __init__(self, fun):
		self.fun = fun;

	def __get__(self, instance, owner):
		def class_method(*args, **kargs):
			return self.fun(owner, *args, **kargs)

		return class_method

def my_class_method(fun):
	return MyClassObject(fun)

class C(object):
	"""docstring for C"""

	def test_instance_method(self):
		print(self)

	@staticmethod
	def test_static_method(message):
		print(message)

	@my_static_method
	def test_my_static_method(message):
		print(message)

	@classmethod
	def test_class_method(cls):
		print(cls)

	@my_class_method
	def test_my_class_method(cls):
		print(cls)

print("\n实例方法测试")
c = C()
print(C.test_instance_method)
print(C.__dict__["test_instance_method"])
print(c.test_instance_method)	
C.test_instance_method(c)
c.test_instance_method()

print("\n静态方法测试")
print(C.test_static_method)
print(C.__dict__["test_static_method"])
print(c.test_static_method)
C.test_static_method("静态方法测试")
c.test_static_method("静态方法测试")

print("\n自定义静态方法测试")
print(C.test_my_static_method)
print(C.__dict__["test_my_static_method"])
print(c.test_my_static_method)
C.test_my_static_method("自定义静态方法测试")
c.test_my_static_method("自定义静态方法测试")

print("\n类方法测试")
print(C.test_class_method)
print(C.__dict__["test_class_method"])
print(c.test_class_method)
C.test_class_method()
c.test_class_method()

print("\n自定义类方法测试")
print(C.test_my_class_method)
print(C.__dict__["test_my_class_method"])
print(c.test_my_class_method)

C.test_my_class_method()
c.test_my_class_method()

print("\n对象上的方法不会返回绑定方法，对象描述符也不会起作用")
def test(self):
	print(self)

c.test = test

c.test("测试")